// src/entities/project-metric.entity.ts
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne } from 'typeorm';
import { Project } from './project.entity';

@Entity('project_metrics')
export class ProjectMetric {
  @PrimaryGeneratedColumn()
  id: number;

  @ManyToOne(() => Project, (project) => project.metrics)
  project: Project;

  @Column({ type: 'int' })
  cpuUsage: number;

  @Column({ type: 'int' })
  memoryUsage: number;

  @Column({ type: 'int' })
  requestCount: number;

  @Column({ type: 'int' })
  errorCount: number;

  @Column({ type: 'decimal', precision: 6, scale: 2 })
  responseTime: number;

  @Column({
    type: 'timestamp',
    default: () => 'CURRENT_TIMESTAMP',
  })
  collectedAt: Date;
}
